<?php
class UsuariosAdminController extends AppController {

	var $name = 'UsuariosAdmin';
	var $uses = array('Usuario');
	var $helpers = array('Html', 'Form' );

	function beforeFilter(){
		$this->MenuCreator->setModulo($this->name);
		$this->set('menu', $this->getMenuElements());		
	}
	
	function login(){
		if(!empty($this->data)) {
			$someone = $this->Usuario->findByEmail($this->data['Usuario']['email']);

			if(!empty($someone['Usuario']['password']) && $someone['Usuario']['password'] == $this->data['Usuario']['password']) {
				$this->Session->write('User', $someone['Usuario']['id']);				
				$this->redirect('/siniestros');
            }
            else{
				$this->Session->setFlash('Login invalido, el usuario o password no es v&aacute;lido.');								
            }
		}
	}
	
    function logout(){
        $this->Session->delete('User');
        $this->redirect('/');
    }

    function index(){
    }
}
?>